/*
 * Name: EventsData
 * Author: Sam Oakley
 * Date: 22/3/2010
 * Version Number: 1.2
 * Description: Event database class. Handles creating a database on first use and
 * deleting it on app version change
 * Changes History: 
 * 1.0 Created class
 * 1.1 Added 'attending'
 * 1.2 Added 'tagline'
 */
package com.blork.rag;

import static android.provider.BaseColumns._ID;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class EventsData extends SQLiteOpenHelper{
	private static final String DATABASE_NAME = "events.db";
	private static final int DATABASE_VERSION = 54; 
	
	/** Create a helper object for the Events database */
	public EventsData(Context ctx){
		super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
	}
	
	@Override
	public void onCreate(SQLiteDatabase db){
		db.execSQL("CREATE TABLE events (" 
				+_ID+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + 
						"title TEXT NOT NULL," +
						"logo TEXT," +
						"description TEXT NOT NULL," +
						"tagline TEXT NOT NULL," +
						"date_start INT NOT NULL, " +
						"date_end INT NOT NULL," +
						"location_name TEXT NOT NULL," +
						"location_long TEXT NOT NULL," + 
						"location_lat TEXT NOT NULL," +
						"ticket_price TEXT," +
						"sponsorship_min TEXT," +
						"sponsorship_deadline INT," +
						"signup_start INT," +
						"signup_end INT," +
						"capacity TEXT," +
						"money_raised TEXT," +
						"attending INT NOT NULL," +
						"passport INT," +
						"emergency INT," +
						"doctor INT," +
						"address INT," +
						"hoody INT," +
						"tshirt INT," +
						"attendees INT," +
						"fb_eid INT," +
						"rag_id INT," +
						"open INT);");
	}
	

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
		db.execSQL("DROP TABLE IF EXISTS events");
		onCreate(db);
	}
}
